package com.t4l.server.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.t4l.server.persistence.T4LEntity;

import net.sf.json.JSONObject;

@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "EMAIL"))
public class T4LUser extends T4LEntity{

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Column
	private String name;

	@Column
	private String lastName;

	@Column
	private String email;

	@Column
	private String password;

	public T4LUser() {
		super();
	}

	public T4LUser(Long id, String name, String lastName, String email,
			String password) {
		this();
		this.id = id;
		this.name = name;
		this.lastName = lastName;
		this.email = email;
		this.password = password;
	}

	public Long getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public JSONObject toJson() {
		JSONObject jso = new JSONObject();
		jso.put("id", id);
		jso.put("name", name);
		jso.put("lastName", lastName);
		jso.put("email", email);
		jso.put("password", password);
		return jso;
	}
}
